package com.riant.test8;

import javax.jws.Oneway;
import javax.swing.text.html.HTMLDocument;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;

public class Test4 {
    public static void main(String[] args) {
        Collection<String> collection=new ArrayList<>();
        collection.add("str");
        collection.add("str");
        Iterator iterator=collection.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
        //String[] strs= (String[]) collection.toArray();
        Object[] objects= collection.toArray();
        for(int i=0;i<objects.length;i++){
            System.out.println(objects[i]);
        }
        System.out.println( collection.contains("str"));
        collection.remove("str");
        iterator=collection.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
        System.out.println(collection.size());
        collection.clear();
        System.out.println(collection.size());
        Collection<String> collection1=Collections.unmodifiableCollection(collection);
        collection1.add("str");
    }
}
